package top.easyblog.core.dao.auto.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
import top.easyblog.core.dao.auto.model.CompressionCode;
import top.easyblog.core.dao.auto.model.CompressionCodeExample;

@Mapper
@Repository
public interface CompressionCodeMapper {
    @SelectProvider(type=CompressionCodeSqlProvider.class, method="countByExample")
    long countByExample(CompressionCodeExample example);

    @DeleteProvider(type=CompressionCodeSqlProvider.class, method="deleteByExample")
    int deleteByExample(CompressionCodeExample example);

    @Delete({
        "delete from compression_code",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into compression_code (compression_code, status, ",
        "sequence_value, strategy, ",
        "deleted, create_time, ",
        "update_time)",
        "values (#{compressionCode,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, ",
        "#{sequenceValue,jdbcType=VARCHAR}, #{strategy,jdbcType=VARCHAR}, ",
        "#{deleted,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(CompressionCode record);

    @InsertProvider(type=CompressionCodeSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(CompressionCode record);

    @SelectProvider(type=CompressionCodeSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="compression_code", property="compressionCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="sequence_value", property="sequenceValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="strategy", property="strategy", jdbcType=JdbcType.VARCHAR),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<CompressionCode> selectByExample(CompressionCodeExample example);

    @Select({
        "select",
        "id, compression_code, status, sequence_value, strategy, deleted, create_time, ",
        "update_time",
        "from compression_code",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="compression_code", property="compressionCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="sequence_value", property="sequenceValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="strategy", property="strategy", jdbcType=JdbcType.VARCHAR),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    CompressionCode selectByPrimaryKey(Long id);

    @UpdateProvider(type=CompressionCodeSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") CompressionCode record, @Param("example") CompressionCodeExample example);

    @UpdateProvider(type=CompressionCodeSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") CompressionCode record, @Param("example") CompressionCodeExample example);

    @UpdateProvider(type=CompressionCodeSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CompressionCode record);

    @Update({
        "update compression_code",
        "set compression_code = #{compressionCode,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=TINYINT},",
          "sequence_value = #{sequenceValue,jdbcType=VARCHAR},",
          "strategy = #{strategy,jdbcType=VARCHAR},",
          "deleted = #{deleted,jdbcType=BIT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CompressionCode record);
}